﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using EnhancedWebPart;
using System.Reflection;
using System.Collections.Generic;
using EnhancedWebPart.Localization;

namespace EnhancedWebpartProject.EnhancedVisualWebPart
{
    [ToolboxItemAttribute(false)]
    public class EnhancedVisualWebPart : EnhancedWebPart.EnhancedWebPart
    {
    protected override IEnumerable<Assembly> GetCompositionAssemblies()
    {
        return new Assembly[] { Assembly.GetAssembly(typeof(DisplayableFilterSetting)) };
    }

    [Personalizable(PersonalizationScope.Shared),
    EnhancedWebPartProperty(true),
    WebBrowsable(false),
    WebDisplayName("Filter"),
    Category("Preferences")]
    public FilterSetting Filter { get; set; }

        [Personalizable(PersonalizationScope.Shared),
        EnhancedWebPartProperty(true),
        WebBrowsable(false),
        WebDisplayName("check this!"),
        Category("Preferences")]
        public bool CheckThis { get; set; }

        [Personalizable(PersonalizationScope.Shared),
        EnhancedWebPartProperty(true),
        WebBrowsable(false),
        WebDisplayName("SPUser sample property"),
        Category("Preferences")]
        public SPUser SPUserSample { get; set; }

        [Personalizable(PersonalizationScope.Shared),
        EnhancedWebPartProperty(true),
        WebBrowsable(false),
        LocalizedWebDisplayName("SimplePropertyName", "Resource1"),
        LocalizedDescription("SimplePropertyDescription", "Resource1"),
        Category("Localization")]
        public int SimpleProperty { get; set; }

        [Personalizable(PersonalizationScope.Shared),
        EnhancedWebPartProperty(true),
        WebBrowsable(false),
        LocalizedWebDisplayName("SimplePropertyName", "Resource1"),
        LocalizedDescription("SimplePropertyDescription", "Resource1"),
        Category("Localization")]
        public DropDownEnum DropDownProperty { get; set; }


        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/EnhancedWebpartProject/EnhancedVisualWebPart/EnhancedVisualWebPartUserControl.ascx";

        protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(_ascxPath);
            Controls.Add(control);
        }
    }
}
